package com.jams.goodox.entity.resp;

import android.text.TextUtils;

import com.jams.goodox.entity.Mapper;
import com.jams.goodox.entity.MeetHistory;
import com.jams.goodox.entity.PageInfo;
import com.jams.goodox.entity.PayInfo;
import com.jams.goodox.net.BaseEntity;
import com.jams.goodox.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jams_zhen on 2017/6/7.
 */

public class MeetHistoryResp extends BaseEntity{

    private DataBean data;

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean implements Mapper<List<MeetHistory>>{
        private PageInfo pageInfo;
        private List<ResultListBean> resultList;

        public List<ResultListBean> getResultList() {
            return resultList;
        }

        public void setResultList(List<ResultListBean> resultList) {
            this.resultList = resultList;
        }

        public PageInfo getPageInfo() {
            return pageInfo;
        }

        public void setPageInfo(PageInfo pageInfo) {
            this.pageInfo = pageInfo;
        }

        @Override
        public List<MeetHistory> transform() {
            List<MeetHistory> historyList=new ArrayList<>();
            if(resultList!=null&&resultList.size()>0){
                for(ResultListBean resultListBean:resultList){
                    historyList.add(resultListBean.transform());
                }
            }
            return historyList;
        }

        public static class ResultListBean implements Mapper<MeetHistory>{
            private String address;
            private String beginTime;
            private String endTime;
            private Object isEnd;
            private int isPay;
            private String orderId;
            private String orderNum;
            private int orderStatus;
            private String orderTime;
            private String placeDate;
            private String placeTypeName;
            private String status;
            private double totalMoney;
            private double total;
            private PayInfo pay;
            private String redPacketMoney;

            private static final int OrderNeedPay=1;
            private static final int OrderComplete=2;
            private static final int OrderClose=3;

            public String getAddress() {
                return address;
            }

            public void setAddress(String address) {
                this.address = address;
            }

            public String getBeginTime() {
                return beginTime;
            }

            public void setBeginTime(String beginTime) {
                this.beginTime = beginTime;
            }

            public String getEndTime() {
                return endTime;
            }

            public void setEndTime(String endTime) {
                this.endTime = endTime;
            }

            public Object getIsEnd() {
                return isEnd;
            }

            public void setIsEnd(Object isEnd) {
                this.isEnd = isEnd;
            }

            public int getIsPay() {
                return isPay;
            }

            public void setIsPay(int isPay) {
                this.isPay = isPay;
            }

            public String getOrderId() {
                return orderId;
            }

            public void setOrderId(String orderId) {
                this.orderId = orderId;
            }

            public String getOrderNum() {
                return orderNum;
            }

            public void setOrderNum(String orderNum) {
                this.orderNum = orderNum;
            }

            public int getOrderStatus() {
                return orderStatus;
            }

            public void setOrderStatus(int orderStatus) {
                this.orderStatus = orderStatus;
            }

            public String getOrderTime() {
                return orderTime;
            }

            public void setOrderTime(String orderTime) {
                this.orderTime = orderTime;
            }

            public String getPlaceDate() {
                return placeDate;
            }

            public void setPlaceDate(String placeDate) {
                this.placeDate = placeDate;
            }

            public String getPlaceTypeName() {
                return placeTypeName;
            }

            public void setPlaceTypeName(String placeTypeName) {
                this.placeTypeName = placeTypeName;
            }

            public String getStatus() {
                return status;
            }

            public void setStatus(String status) {
                this.status = status;
            }

            @Override
            public MeetHistory transform() {
                MeetHistory meetHistory=new MeetHistory();
                meetHistory.setEnTime(OrderNeedPay==orderStatus?"":status);//右上角订单状态
                meetHistory.setNeedPay(orderStatus==OrderNeedPay);//是否待付款
                meetHistory.setPayEmptyTime(status);

                meetHistory.setMeetContinueTime(String.format("%s %s—%s",placeDate,beginTime,endTime));
                meetHistory.setMeetRoom(TextUtils.isEmpty(placeTypeName)?"":placeTypeName);
                meetHistory.setMeetPlace(TextUtils.isEmpty(address)?"":address);
                meetHistory.setOrderNum(TextUtils.isEmpty(orderNum)?"":orderNum);
                meetHistory.setOrderId(orderId);
                meetHistory.setTotalMoney(total);//易乱处，总金额是total
                meetHistory.setPay(pay);
                meetHistory.setRedPacket(StringUtils.toDouble(redPacketMoney));
                return meetHistory;
            }
        }
    }
}
